package com.example.module_service.model

import com.example.lib_net.HttpManger
import com.example.module_service.api.ServiceApiService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Qualifier
import javax.inject.Singleton

@Qualifier//声明依赖注入，用于区分多个实例
@Retention(AnnotationRetention.BINARY)
annotation class Service{

}


@Module
@InstallIn(SingletonComponent::class)
object WorkModel {

    @Service
    @Provides
    @Singleton
    fun provideRetrofit():Retrofit{
        return HttpManger.getRetrofit()
    }

    @Provides
    @Singleton
    fun provideApiService(@Service retrofit: Retrofit):ServiceApiService{
        return retrofit.create(ServiceApiService::class.java)
    }
}